package com.aboo.service;

import com.aboo.api.EmployeeService;
import com.aboo.domain.Employee;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;

import java.math.BigDecimal;
import java.util.Random;

@Slf4j
@Service(group = "enterprise", version = "1.0")
public class ProviderEmployee01Service implements EmployeeService {

    @Override
    public Employee getById(Long id) {
        Employee employee = new Employee();
        employee.setId(id);
        employee.setAge(20 + new Random().nextInt(10));
        employee.setCardNo(String.format("%4d", new Random().nextInt(10000)));
        employee.setName("employee" + id);
        employee.setWeight(new BigDecimal("65.38"));
        return employee;
    }

    @Override
    public int saveEmployee(Employee employee) {
        log.info(JSONObject.toJSONString(employee));
        return 1;
    }

}
